package com.example.mybaties.testone.custom;

import com.example.mybaties.testone.controller.SysDictController;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;
import org.springframework.core.io.UrlResource;

import javax.annotation.Resource;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class ResourceTest1 {

    private Logger logger = LogManager.getLogger(ResourceTest1.class);

    @Test
    public void test1() throws Exception{
        StringBuilder sb = new StringBuilder();
        UrlResource urlResource = new UrlResource("http://www.whctco.com/download/JQBCODE.txt");
        InputStream in = urlResource.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(in, "GBK"));
        String str = null;
        while((str = br.readLine()) != null){
            sb.append(str);
            sb.append("\n");
        }
        logger.debug(sb);
    }

}
